<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
USAGE:

Simple:

<?php echo $this->getLayout()->createBlock('Magento\Customer\Block\Widget\Dob')
   ->setDate($this->getCustomer()->getDob())
   ->toHtml() ?>

For checkout/onepage/billing.phtml:

<?php echo $this->getLayout()->createBlock('Magento\Customer\Block\Widget\Dob')
   ->setDate($this->getCustomer()->getDob())
   ->setFieldIdFormat('billing:%s')
   ->setFieldNameFormat('billing[%s]')
   ->toHtml() ?>

NOTE: Regarding styles - if we leave it this way, we'll move it to boxes.css
      Alternatively we could calculate widths automatically using block input parameters.
*/

/**
 * @see \Magento\Customer\Block\Widget\Dob
 */
?>
<div class="field dob<?php if ($this->isRequired()) echo ' required' ?>">
    <label class="label" for="<?php echo $this->getFieldId('month')?>"><span><?php echo __('Date of Birth') ?></span></label>
    <div class="control customer-dob">
        <div class="fields group group-3">
        <?php
            $this->setDateInput('d',
                '<div class="field dob-day day">
                     <label class="label" for="' . $this->getFieldId('day') . '"><span>' . __('DD') . '</span></label>
                     <div class="control"><input type="text" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay() . '" title="' . __('Day') . '" class="input-text validate-custom" ' . $this->getFieldParams() . '></div>
                 </div>'
            );

            $this->setDateInput('m',
                '<div class="field dob-month month">
                     <label class="label" for="' . $this->getFieldId('month') . '"><span>' . __('MM')  . '</span></label>
                     <div class="control"><input type="text" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth()  . '" title="' . __('Month')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . '></div>
                 </div>'
            );

            $this->setDateInput('y',
                '<div class="field dob-year year">
                     <label class="label" for="' . $this->getFieldId('year') . '"><span>' . __('YYYY')  . '</span></label>
                     <div class="control"><input type="text" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear()  . '" title="' . __('Year')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . '></div>
                 </div>'
            );
        ?>
        <?php echo $this->getSortedDateInputs() ?>
        </div>
        <input type="hidden" id="<?php echo $this->getFieldId('full')?>" name="<?php echo $this->getFieldName('dob')?>" data-validate="{'validate-dob': ['.dob-day', '.dob-month', '.dob-year', <?php echo $this->isRequired() ? 'true' : 'false' ?>]<?php if ($this->getMinDateRange() && $this->getMaxDateRange()):?>, 'validate-date-between':['<?php echo $this->getMinDateRange()?>', '<?php echo $this->getMaxDateRange()?>']<?php endif;?>}">
        <div class="validation-advice" id="<?php echo $this->getFieldId('date-advice')?>" style="opacity:0.999999; display:none;"></div>
    </div>
</div>
